package com.gzr.collection.stream;

import java.util.*;
import java.util.stream.Stream;

/**
 * 获取stream
 */
public class StreamDemo02 {
    public static void main(String[] args) {
        //1、获取集合的stream流， 调用集合提供的stream()方法
        Collection<String> list = new ArrayList<>();
        Stream<String> stream = list.stream();

        //2、Map集合怎么拿stream流
        HashMap<Object, Object> hashMap = new HashMap<>();
        //获取键
        Stream<Object> stream1 = hashMap.keySet().stream();
        //获取值
        Stream<Object> stream2 = hashMap.values().stream();
        //获取键值对
        Stream<Map.Entry<Object, Object>> stream3 = hashMap.entrySet().stream();

        //3、获取数组的流
        String[] names = {"张三丰","张无忌"};
        Stream<String> stream4 = Arrays.stream(names);
        System.out.println(stream4.count());
        Stream<String> stream5 = Stream.of(names);
        Stream<String> stream6 = Stream.of("张三丰","张无忌");
    }
}
